package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by HK on 16/9/19.
 * 产品
 */
@Entity
@Table(name = "product")
@DynamicInsert
@DynamicUpdate
public class Product extends IDEntityMall {
    /**
     * 分销产品id
     */
    @Column(columnDefinition = "bigint comment '分销产品id'")
    private Long marketId;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '分销产品 平台id 冗余查询'")
    private Long marketMallId;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '分销产品 商家id 冗余查询'")
    private Long marketMerchantId;
    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment '分销产品 商家名称 冗余查询'")
    private String marketMerchantName;
    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment '名称'")
    private String name;
    /**
     *
     */
    @Column(columnDefinition = "varchar(20) comment '类型 ALL(\"全部\"), GOODS(\"商品\"), SERVICE(\"服务\")'")
    @Enumerated(EnumType.STRING)
    private ProductType type;
    /**
     *
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '原价'")
    private BigDecimal basePrice;
    /**
     *
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '售价'")
    private BigDecimal sellPrice;
    /**
     *
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '运费'")
    private BigDecimal carriage;
    /**
     *
     */
    @Column(columnDefinition = "DATETIME comment '有效期开始时间'")
    private Date dateEnabled;
    /**
     *
     */
    @Column(columnDefinition = "DATETIME comment '有效期结束时间'")
    private Date dateDisabled;
    /**
     *
     */
    @Column(columnDefinition = "bit comment '是否支持过期退'")
    private Boolean refundable = false;
    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment '产品编码'")
    private String barcode;
    /**
     *
     */
    @Column(columnDefinition = "bit comment '是否立即开售'")
    private Boolean sellnow;
    /**
     *
     */
    @Column(columnDefinition = "DATETIME comment '开售时间'")
    private Date dateSelling;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '限购数量'")
    private Long limitCount;
    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment 'LOGO图'")
    private String logoUrl;
    /**
     *
     */
    @Column(columnDefinition = "text comment 'LOGO图 多张'")
    private String logoUrls;
    /**
     *
     */
    @Column(columnDefinition = "text comment '卖点介绍'")
    private String note;
    /**
     *
     */
    @Column(columnDefinition = "varchar(20) comment '状态 SELLING(\"在售\"), SUPPLIER_CANCEL_SOLDOUT(\"分销市场 供应商取消供货 已下架\"),DISTRIBUTOR_CANCEL_SOLDOUT(\"分销市场 分销商取消代销 已下架\"), SOLDOUT(\"已下架\"), EXPIRED(\"已过期\"), DELETED(\"已删除\"), WAIT_APPLY(\"待申请\"), WAIT_AUDIT(\"待审核\"), AUDIT_PASS(\"审核通过\"), AUDIT_FAIL(\"审核不通过\")'")
    @Enumerated(EnumType.STRING)
    private ProductStatus status;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '平台 id'")
    private Long mallId;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '商家 id'")
    private Long merchantId;
    /**
     *
     */
    @Column(columnDefinition = "varchar(100) comment '产品所属商家名称'")
    private String merchantName;
    @Column(columnDefinition = "varchar(30) comment '服务费比率'")
    private String serveRate;
    /**
     *
     */
    @Column(columnDefinition = "varchar(30) comment '支持的物流类型 SHOP_PICKUP(\"到店自取\"), SHIPPING(\"物流\"), SHOP_PICKUP_AND_SHIPPING(\"物流和到店自取\")'", name = "shipping_type")
    @Enumerated(EnumType.STRING)
    private ProductShippingType shippingType;
    /**
     *
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '分销佣金'")
    private BigDecimal resellFee = BigDecimal.ZERO;
    /**
     *
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '分享返利'")
    private BigDecimal shareFee = BigDecimal.ZERO;
    /**
     *
     */
    @Column(columnDefinition = "varchar(30) comment '分销类型 IN_PLATFORM(\"平台内\"), OUT_PLATFORM(\"平台外\")'")
    @Enumerated(EnumType.STRING)
    private ProductMarketPlatformType marketPlatformType;
    /**
     *
     */
    @Column(columnDefinition = "bit comment '是否在分销市场展示'")
    private Boolean isRecommend = false;
    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment '产品推广二维码图片路径'")
    private String promoteUrl;
    /**
     *
     */
    @Column(columnDefinition = "varchar(30) comment '适用门店类型 ALL(\"所有门店\"), PART(\"指定门店\")'")
    @Enumerated(EnumType.STRING)
    private ProductMerchantStoreType productMerchantStoreType;

    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment '审核备注'")
    private String auditRemark;

    /**
     *
     */
    @Column(columnDefinition = "varchar(255) comment 'C端访问URL'")
    private String cAccessUrl;
    /**
     *
     */
    @Column(columnDefinition = "bigint comment '产品库存id'", nullable = false)
    private Long productQuantityId;

    /**
     *
     */
    @Column(columnDefinition = "varchar(150) comment '产品别名'")
    private String aliasName;

    @Column(columnDefinition = "varchar (20) default 'GENERAL' comment '产品客户端类型'")
    @Enumerated(EnumType.STRING)
    protected ProductClientType productClientType = ProductClientType.GENERAL;

    @Column(columnDefinition = "bigint default 0 comment '排序号'")
    private Long sortNum;

    public static final String CHECK_TYPE_IS_NOT_NULL = "产品类型 不能为空";
    public static final String CHECK_NAME_IS_NOT_NULL = "产品名称 不能为空";
    public static final String CHECK_BASE_PRICE_IS_NOT_NULL = "产品原价 不能为空";
    public static final String CHECK_SELL_PRICE_IS_NOT_NULL = "产品售价 不能为空";
    public static final String CHECK_QUANTITY_IS_NOT_NULL = "产品库存 不能为空";
    public static final String CHECK_CATEGORY_IDS_IS_NOT_NULL = "产品分类 不能为空";
    public static final String CHECK_LOGO_URLS_IS_NOT_NULL = "产品LOGO图 不能为空";
    public static final String CHECK_NOTE_IS_NOT_NULL = "产品卖点介绍 不能为空";
    public static final String CHECK_MANUAL_IS_NOT_NULL = "产品购买须知 不能为空";
    public static final String CHECK_INTRODUCE_IS_NOT_NULL = "产品图文详情 不能为空";
    public static final String CHECK_MASTER_PRODUCT_ID_IS_NOT_NULL = "主产品ID 不能为空";
    public static final String CHECK_DATE_ENABLED_IS_NOT_NULL = "有效期开始时间格式有误 格式:yyyy-MM-dd HH:mm:ss";
    public static final String CHECK_DATE_DISABLED_IS_NOT_NULL = "有效期结束时间格式有误 格式:yyyy-MM-dd HH:mm:ss";
    public static final String CHECK_LIMIT_COUNT_IS_NOT_NULL = "限购数量 不能为空,默认值为0";

    public Long getMarketId() {
        return marketId;
    }

    public void setMarketId(Long marketId) {
        this.marketId = marketId;
    }

    public Long getMarketMallId() {
        return marketMallId;
    }

    public void setMarketMallId(Long marketMallId) {
        this.marketMallId = marketMallId;
    }

    public Long getMarketMerchantId() {
        return marketMerchantId;
    }

    public void setMarketMerchantId(Long marketMerchantId) {
        this.marketMerchantId = marketMerchantId;
    }

    public String getMarketMerchantName() {
        return marketMerchantName;
    }

    public void setMarketMerchantName(String marketMerchantName) {
        this.marketMerchantName = marketMerchantName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ProductType getType() {
        return type;
    }

    public void setType(ProductType type) {
        this.type = type;
    }

    public BigDecimal getBasePrice() {
        return basePrice;
    }

    public void setBasePrice(BigDecimal basePrice) {
        this.basePrice = basePrice;
    }

    public BigDecimal getSellPrice() {
        return sellPrice;
    }

    public void setSellPrice(BigDecimal sellPrice) {
        this.sellPrice = sellPrice;
    }

    public BigDecimal getCarriage() {
        return carriage;
    }

    public void setCarriage(BigDecimal carriage) {
        this.carriage = carriage;
    }

    public Date getDateEnabled() {
        return dateEnabled;
    }

    public void setDateEnabled(Date dateEnabled) {
        this.dateEnabled = dateEnabled;
    }

    public Date getDateDisabled() {
        return dateDisabled;
    }

    public void setDateDisabled(Date dateDisabled) {
        this.dateDisabled = dateDisabled;
    }

    public Boolean getRefundable() {
        return refundable;
    }

    public void setRefundable(Boolean refundable) {
        this.refundable = refundable;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public Boolean getSellnow() {
        return sellnow;
    }

    public void setSellnow(Boolean sellnow) {
        this.sellnow = sellnow;
    }

    public Date getDateSelling() {
        return dateSelling;
    }

    public void setDateSelling(Date dateSelling) {
        this.dateSelling = dateSelling;
    }

    public Long getLimitCount() {
        return limitCount;
    }

    public void setLimitCount(Long limitCount) {
        this.limitCount = limitCount;
    }

    public String getLogoUrl() {
        return logoUrl;
    }

    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }

    public String getLogoUrls() {
        return logoUrls;
    }

    public void setLogoUrls(String logoUrls) {
        this.logoUrls = logoUrls;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public ProductStatus getStatus() {
        return status;
    }

    public void setStatus(ProductStatus status) {
        this.status = status;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    public String getServeRate() {
        return serveRate;
    }

    public void setServeRate(String serveRate) {
        this.serveRate = serveRate;
    }

    public ProductShippingType getShippingType() {
        return shippingType;
    }

    public void setShippingType(ProductShippingType shippingType) {
        this.shippingType = shippingType;
    }

    public BigDecimal getResellFee() {
        return resellFee;
    }

    public void setResellFee(BigDecimal resellFee) {
        this.resellFee = resellFee;
    }

    public BigDecimal getShareFee() {
        return shareFee;
    }

    public void setShareFee(BigDecimal shareFee) {
        this.shareFee = shareFee;
    }

    public ProductMarketPlatformType getMarketPlatformType() {
        return marketPlatformType;
    }

    public void setMarketPlatformType(ProductMarketPlatformType marketPlatformType) {
        this.marketPlatformType = marketPlatformType;
    }

    public Boolean getRecommend() {
        return isRecommend;
    }

    public void setRecommend(Boolean recommend) {
        isRecommend = recommend;
    }

    public String getPromoteUrl() {
        return promoteUrl;
    }

    public void setPromoteUrl(String promoteUrl) {
        this.promoteUrl = promoteUrl;
    }

    public ProductMerchantStoreType getProductMerchantStoreType() {
        return productMerchantStoreType;
    }

    public void setProductMerchantStoreType(ProductMerchantStoreType productMerchantStoreType) {
        this.productMerchantStoreType = productMerchantStoreType;
    }

    public String getAuditRemark() {
        return auditRemark;
    }

    public void setAuditRemark(String auditRemark) {
        this.auditRemark = auditRemark;
    }

    public String getcAccessUrl() {
        return cAccessUrl;
    }

    public void setcAccessUrl(String cAccessUrl) {
        this.cAccessUrl = cAccessUrl;
    }

    public Long getProductQuantityId() {
        return productQuantityId;
    }

    public void setProductQuantityId(Long productQuantityId) {
        this.productQuantityId = productQuantityId;
    }

    public String getAliasName() {
        return aliasName;
    }

    public void setAliasName(String aliasName) {
        this.aliasName = aliasName;
    }

    public ProductClientType getProductClientType() {
        return productClientType;
    }

    public void setProductClientType(ProductClientType productClientType) {
        this.productClientType = productClientType;
    }

    public Long getSortNum() {
        return sortNum;
    }

    public void setSortNum(Long sortNum) {
        this.sortNum = sortNum;
    }

    @Override
    public String toString() {
        return "Product{" +
                "marketId=" + marketId +
                ", marketMallId=" + marketMallId +
                ", marketMerchantId=" + marketMerchantId +
                ", marketMerchantName='" + marketMerchantName + '\'' +
                ", name='" + name + '\'' +
                ", type=" + type +
                ", basePrice=" + basePrice +
                ", sellPrice=" + sellPrice +
                ", carriage=" + carriage +
                ", dateEnabled=" + dateEnabled +
                ", dateDisabled=" + dateDisabled +
                ", refundable=" + refundable +
                ", barcode='" + barcode + '\'' +
                ", sellnow=" + sellnow +
                ", dateSelling=" + dateSelling +
                ", limitCount=" + limitCount +
                ", logoUrl='" + logoUrl + '\'' +
                ", logoUrls='" + logoUrls + '\'' +
                ", note='" + note + '\'' +
                ", status=" + status +
                ", mallId=" + mallId +
                ", merchantId=" + merchantId +
                ", merchantName='" + merchantName + '\'' +
                ", serveRate='" + serveRate + '\'' +
                ", shippingType=" + shippingType +
                ", resellFee=" + resellFee +
                ", shareFee=" + shareFee +
                ", marketPlatformType=" + marketPlatformType +
                ", isRecommend=" + isRecommend +
                ", promoteUrl='" + promoteUrl + '\'' +
                ", productMerchantStoreType=" + productMerchantStoreType +
                ", auditRemark='" + auditRemark + '\'' +
                ", cAccessUrl='" + cAccessUrl + '\'' +
                ", productQuantityId=" + productQuantityId +
                ", aliasName='" + aliasName + '\'' +
                ", productClientType=" + productClientType +
                ", sortNum=" + sortNum +
                '}';
    }
}
